<template>
	<div class="login w-full h-full box-border">
    <div class="p-4 text-red-600">
      login 123
      <el-button @click="login" type="primary" :loading="loading">登录</el-button>
    </div>
  </div>
</template>
<script>
import {setToken} from "@/utils/auth"
export default {
	name: 'login',
	data() {
		return {
      loading:false
    }
	},
  methods: {
     async login(){
      this.loading = true
      try {
      const res = await this.$api.login({
        username:"admin",
        password:"123456"
      })

      if(res.data.code === 200) {
        setToken(res.data.data.token)
        const logindata = await this.$store.dispatch('user/setAsyncUserInfo',123)
        if(logindata) this.$router.replace('/')
      }

      } catch (error) {
        console.log(error);
      }finally{
        this.loading = false
      }
      
    }
  },
}
</script>
<style lang="less">
@import "~@/index.less";
.login{
  
}
</style>